home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_exmh.idb / usr / freeware / lib / exmh-2.5 / help.tcl.z / help.tcl
Text File  |  2002-07-08  |  4KB  |  128 lines

  1. # help.tcl
  2. #
  3. # Help and color key.
  4. #
  5. # Copyright (c) 1993 Xerox Corporation.
  6. # Use and copying of this software and preparation of derivative works based
  7. # upon this software are permitted. Any distribution of this software or
  8. # derivative works must comply with all applicable United States export
  9. # control laws. This software is made available AS IS, and Xerox Corporation
  10. # makes no warranty about the software, its performance or its conformity to
  11. # any specification.
  12.  
  13. proc Help_KeyDisplay {} {
  14.     global fdisp
  15.  
  16.     if [Exwin_Toplevel .key "Exmh Key" Key] {
  17.     set key .key
  18.     set b .key.but
  19.  
  20.     set l [Widget_Label $b]
  21.     if {[winfo depth .] > 4} {
  22.         $l configure -text "color"
  23.     } else {
  24.         $l configure -text "monochrome"
  25.     }
  26.  
  27.     set font $fdisp(font)
  28.  
  29.     set key [Widget_Frame .key rim Rim]
  30.     $key configure -borderwidth 10
  31.     
  32.     set t [Widget_SimpleText $key t {top fillx} -width 34 -height 12 -font $font -wrap none]
  33.     Ftoc_ColorConfigure $t
  34.     $t configure -state normal
  35.     $t delete 0.0 end
  36.     $t insert insert "current message\nmoved messages\ndeleted messages\nunseen messages\n"
  37.     $t tag add current 1.0 1.end
  38.     $t tag add moved   2.0 2.end
  39.     $t tag add deleted 3.0 3.end
  40.     $t tag add unseen  4.0 4.end
  41.     $t insert insert "\nFolder Label Bindings\n"
  42.     $t insert insert "left          => change folder\n"
  43.     $t insert insert "middle        => view subfolders\n"
  44.     $t insert insert "right         => refile message(s)\n"
  45.     $t insert insert "shift-right   => link message(s)\n"
  46.     $t insert insert "shift-middle  => drag folder\n"
  47.     $t insert insert "control-right => clear target"
  48.     $t configure -state disabled
  49.     
  50.     set c [canvas $key.can -width 20 -height 30]
  51.     pack append $key $c {top expand fill}
  52.     set y [expr [lindex [$c configure -height] 4]/2]
  53.     set x 4
  54.     set x [HelpKeyLabel $c $x $y current $font curtext curbox]
  55.     set x [HelpKeyLabel $c $x $y unseen $font unsntext unsnbox]
  56.     set x [HelpKeyLabel $c $x $y moveTarget $font tartext tarbox]
  57.     Fdisp_LabelConfigure $c
  58.     set w [expr [lindex [$c bbox all] 2] + 5]
  59.     set h [expr [lindex [$c bbox all] 3] + 5]
  60.     $c config -width $w -height $h
  61.     }
  62. }
  63. proc HelpKeyLabel { c x y text font texttag boxtag} {
  64.     global fdisp
  65.     set id [$c create text $x $y -text $text -anchor nw -font $font -tags $texttag]
  66.     set box [Fdisp_Box $c $id leaf]
  67.     $c addtag $boxtag withtag $box
  68.     set bbox [$c bbox $box]
  69.     incr x [expr [lindex $bbox 2]-[lindex $bbox 0]+$fdisp(xgap)]
  70.     return $x
  71. }
  72.  
  73. proc Help { {name {Intro}} {title {Help for exmh} }} {
  74.     global exmh
  75.     if [string match /* $name] {
  76.     # absolute pathname
  77.     set dir [file dirname $name]
  78.     set file [file tail $name]
  79.     set id help$file
  80.     set topic $file
  81.     } else {
  82.     set dir $exmh(library)/html
  83.     set file $dir/$name.html
  84.     set id help$name
  85.     set topic $name
  86.     }
  87.     if [string match *.html $file] {
  88.     return [Html_Window file:$file]
  89.     }
  90.     regsub -all {\.} $id _ id
  91.     if [Exwin_Toplevel .$id "Exmh $topic" Help] {
  92.     Widget_Label .$id.but label {left fill} -text "  $title"
  93.  
  94.     set t [Widget_Text .$id 25 -setgrid true]
  95.     bind $t <Key-Next> {%W yview scroll 1 page}
  96.     bind $t <Key-Prior> {%W yview scroll -1 page}
  97.     bind $t <Key-Home> {%W see 1.0}
  98.     bind $t <Key-End> {%W see end}
  99.     Ftoc_ColorConfigure $t
  100.     $t insert insert "EXMH Version: $exmh(version)\n"
  101.     foreach d [list $dir .] {
  102.         if [catch {open $d/$file} in] {
  103.         continue
  104.         }
  105.         $t insert insert [read $in]
  106.         close $in
  107.         # This is data-dependent..., but cute
  108.         if {$name == "Intro"} {
  109.         set L 26
  110.         $t tag add current $L.0 $L.end ; incr L
  111.         $t tag add deleted $L.0 $L.end ; incr L
  112.         $t tag add moved $L.0 $L.end ; incr L
  113.         $t tag add unseen $L.0 $L.end ; incr L
  114.         }
  115.         $t configure -state disabled
  116.         scan [$t index end] %d height
  117.         if {$height < 25} {
  118.         $t config -height $height
  119.         }
  120.         return $t
  121.     }
  122.     $t insert insert "Cannot find $file file to display"
  123.     $t configure -state disabled
  124.     }
  125.     return .$id.t
  126. }
  127.  
  128.